package router

import (
	"github.com/gin-gonic/gin"
	"sync"
)

var (
	httpRouterOnce   sync.Once
	httpRouterSingle *HttpRouter
)

type Option = gin.HandlerFunc

type HttpRouter struct {
	Groups  []string
	Routers []Router
	Port    string
}

func GetHttpRouter() *HttpRouter {
	httpRouterOnce.Do(func() {
		httpRouterSingle = &HttpRouter{}
	})
	return httpRouterSingle
}

type Router struct {
	Group    string
	Url      string
	Function string
	Ops      []Option
}

func (httpRouter *HttpRouter) RegisterRouteInstance(groups []string, routers []Router, port string) {
	httpRouter.Groups = groups
	httpRouter.Routers = routers
	httpRouter.Port = port
}
